//下拉
var zySelect2 = Vue.extend({
    name: 'zy-select',
    props: {items: {}, multiple: false},
    template:
    '<select   :multiple="multiple"  style="width: 200px">' +
    '     <option  :value="item.value" v-for="item in items">{{ item.name }}</option>' +
    '</select>',
    mounted: function () {
        var vm = this;
        $(this.$el).select2({ data: this.options }).val(this.value).trigger('change').on('change', function () {
            vm.$emit('input', this.value);
        })
    },
    watch: {
        value: function (value) {
            // update value
            $(this.$el).val(value).trigger('change')
        },
        options: function (options) {
            // update options
            $(this.$el).empty().select2({ data: options })
        }
    },

});

//注册select2组件
Vue.component('zySelect2', zySelect2);
